package POJO;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "BRAND", uniqueConstraints = {
		@UniqueConstraint(columnNames = "Brand_Id"),
		@UniqueConstraint(columnNames = "Brand_Name")
})
public class Brand {
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name = "Brand_Id", unique = true)
	private int brandId;
	
	@Column(name = "Brand_Name", unique = true)
	private String brandName;
	
	@Column(name = "Tag")
	private String tag;
	
	@Column(name = "Description")
	private String description;
	
	@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinTable(name = "BRAND_IMAGE", joinColumns = {
			@JoinColumn(name = "Brand_Id", nullable = false, updatable = false)},
			inverseJoinColumns = { @JoinColumn(name = "Image_Id", 
												nullable = false, updatable = false)})
	private Set<Image> images;
	
	public Brand() {
		super();
	}

	public Brand(String brandName) {
		super();
		this.brandName = brandName;
	}

	public Brand(String brandName, String tag, String description) {
		super();
		this.brandName = brandName;
		this.tag = tag;
		this.description = description;
	}

	public Brand(String brandName, String tag, String description,
			Set<Image> images) {
		super();
		this.brandName = brandName;
		this.tag = tag;
		this.description = description;
		this.images = images;
	}

	public int getBrandId() {
		return brandId;
	}

	public void setBrandId(int brandId) {
		this.brandId = brandId;
	}

	public String getBrandName() {
		return brandName;
	}

	public void setBrandName(String brandName) {
		this.brandName = brandName;
	}

	public String getTag() {
		return tag;
	}

	public void setTag(String tag) {
		this.tag = tag;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Set<Image> getImages() {
		return images;
	}

	public void setImages(Set<Image> images) {
		this.images = images;
	}
	
}
